let nums = [99, 99], k = 2
var containsNearbyDuplicate = function (nums, k) {
    if (nums.length == 0) {
        return false
    }
    let obj = {}
    for (let i = 0; i < nums.length; i++) {
        if (obj[nums[i]] != undefined) {
            if (i - obj[nums[i]] <= k) {
                return true
            }
        }
        obj[nums[i]] = i
    }
    return false
};
console.log(containsNearbyDuplicate(nums, k));
